﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.DTO;
using DXApplicationTangche.UC.订单一览新.订单预览新.service;
using DXApplicationTangche.UC.销售记录.service;
using DXApplicationTangche.UC.门店下单.DTO;
using mendian;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.UC.生产计划类型分类管理下单相关内容.定制下单相关.service
{
    public class CustomizedMTOOrderService
    {
        /// <summary>
        /// 春衫定制下单
        /// </summary>
        /// <param name="DTO销售记录"></param>
        public static void saveOrder_SSHIRT_MTO(DTO销售记录 DTO销售记录)
        {
            DTO销售记录.buildOrderDate();
            RestCall.PostHttp(
                URL.接口url + "/MTOOrder/customized/saveOrder_SSHIRT_MTO",
                FunctionHelper.JsonSerialization(DTO销售记录)
            );
        }

        /// <summary>
        /// 水洗标查OrderCommitDTO
        /// </summary>
        /// <param name="barcode"></param>
        public static OrderCommitDTO返回 getOrderCommitDtoByBarcode(String barcode)
        {
            return
                FunctionHelper.JsonDeserialization<OrderCommitDTO返回>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/MTOOrder/customized/getOrderCommitDtoByBarcode?barcode=" + barcode
                    )
                );
        }

        /// <summary>
        /// 款式可选尺码组
        /// </summary>
        /// <param name="styleNameCn"></param>
        /// <returns></returns>
        public static List<String> getMaterialOrderIndexAll(String styleNameCn)
        {
            return
                FunctionHelper.JsonDeserialization<List<String>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/MTOOrder/customized/findSizeCdByStyleNameCn?styleNameCn=" + styleNameCn
                    )
                );
        }
        /// <summary>
        /// 款号查询尺寸
        /// </summary>
        /// <param name="styleSizeCd"></param>
        /// <param name="styleNameCn"></param>
        /// <param name="styleCategoryId"></param>
        /// <returns></returns>
        public static DTOStyleMeasureItems generateStyleMeasureItemsByStyleNameCn(String styleSizeCd, String styleNameCn, String styleCategoryId)
        {
            return
                FunctionHelper.JsonDeserialization<DTOStyleMeasureItems>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/MTOOrder/customized/generateStyleMeasureItemsByStyleNameCn?SIZE_CD=" + styleSizeCd
                                    + "&styleNameCn=" + styleNameCn
                                    + "&categoryId=" + styleCategoryId
                    )
                );
        }
        /// <summary>
        /// 款式查询设计点
        /// </summary>
        /// <param name="styleNameCn"></param>
        /// <returns></returns>
        public static List<DTODesignPoints> generateStyleMeasureItemsByStyleNameCn(String styleNameCn)
        {
            return
                FunctionHelper.JsonDeserialization<List<DTODesignPoints>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/MTOOrder/customized/getCraftFacadeStyleDesignDTOByStyleNameCn?styleNameCn=" + styleNameCn
                    )
                );
        }

        /// <summary>
        /// 下单时修改尺寸
        /// </summary>
        /// <param name="styleNameCn"></param>
        /// <returns></returns>
        public static List<DTODesignPoints> saveMeasureItem(String sessionId, MeasureItemDTO measureItemDTO)
        {
            return
                FunctionHelper.JsonDeserialization<List<DTODesignPoints>>(
                    RestCall.PostHttp(
                        URL.接口url + "/MTOOrder/customized/saveMeasureItem?sessionId=" + sessionId,
                        FunctionHelper.JsonSerialization(measureItemDTO)
                    )
                );
        }
    }
}
